package com.puzzlebazar.client.admin;

import java.util.HashMap;

import com.puzzlebazar.client.main.control.MainController;
import com.puzzlebazar.client.main.control.NamedStateController;
import com.puzzlebazar.client.main.control.StateWithSubstates;
import com.puzzlebazar.client.main.view.MainView;
import com.puzzlebazar.client.user.UserInfo;
import com.puzzlebazar.client.user.UserModel;

public class AdminState extends StateWithSubstates {

	public static final String STATE_TOKEN = "Admin";
	public static final String TITLE = "Administration";
	
	private final AdminController adminController;

	public AdminState(SiteModel siteModel, UserModel model, MainView view, MainController controller) {
		super(model, view, controller);
		
		adminController = new AdminController( siteModel, tabbedView, controller, subStateTokenFactory );
	
	}

	@Override
	public String getStateToken() {
		return STATE_TOKEN;
	}
	
	@Override
	protected String getMainPanelTitle() {
		return TITLE;
	}

	@Override
	protected NamedStateController getSubController() {
		return adminController;
	}

	@Override
	protected void addCustomParams(HashMap<String, String> params) {		
	}	
	

	@Override
	public boolean canEnter() {
		UserInfo userInfo = userModel.getUserInfo(); 
		return userInfo != null && userInfo.isAdministrator();
	}

	@Override
	public void release() {
		super.release();
		adminController.release();
	}
}
